
<?php
// file to test CF_ArrayBySpec
include_once "boot.php";

$data[1]['employeeNumber'] = 1;
$data[1]['lastName'] = 'Grimes';
$data[1]['firstName'] = 'Frank';
$data[1]['extension'] = '209';

$data[2]['employeeNumber'] = 2;
$data[2]['lastName'] = 'Tamod';
$data[2]['firstName'] = 'Jerome';
$data[2]['extension'] = '210';

$data[3]['employeeNumber'] = 3;
$data[3]['lastName'] = 'Fild';
$data[3]['firstName'] = 'Bob';
$data[3]['extension'] = '211';

$data[0]['employeeNumber'] = 4;
$data[0]['lastName'] = 'Raker';
$data[0]['firstName'] = 'Phil';
$data[0]['extension'] = '101';

// define fieldspec


//column settings for
$fieldspec['employeeNumber'] ['show'] = 1;
$fieldspec['employeeNumber'] ['key'] = 1;
$fieldspec['employeeNumber'] ['filter'] = 1;
$fieldspec['employeeNumber'] ['size'] = 20;
$fieldspec['employeeNumber'] ['rows'] = 1;

//column settings for lastName
$fieldspec['lastName'] ['show'] = 'E';
$fieldspec['lastName'] ['add'] = 1;
$fieldspec['lastName'] ['select'] = 'T';
$fieldspec['lastName'] ['filter'] = 1;
//$fieldspec['lastName'] ['filter'] = 1;
$fieldspec['lastName'] ['size'] = 20;
$fieldspec['lastName'] ['rows'] = 1;
$fieldspec['lastName'] ['makefunction'] = 'make_lastName';

//column settings for firstName
$fieldspec['firstName'] ['show'] = 'E';
$fieldspec['firstName'] ['add'] = 1;
$fieldspec['firstName'] ['select'] = 'T';
$fieldspec['firstName'] ['filter'] = 1;
$fieldspec['firstName'] ['size'] = 20;
$fieldspec['firstName'] ['rows'] = 1;

//column settings for extension
$fieldspec['extension'] ['show'] = 'E';
$fieldspec['extension'] ['add'] = 1;
$fieldspec['extension'] ['select'] = 'T';
$fieldspec['extension'] ['filter'] = 1;
$fieldspec['extension'] ['size'] = 20;
$fieldspec['extension'] ['rows'] = 1;


//include_once 'CF_ArrayBySpec.php';

class specialArray extends CF_ArrayBySpec {

	function make_lastName($input){
		return 'Really!  ' .$this->currentrow['firstName'] . " " . $input;
	}

}

echo "<pre>";
print_r($data);
echo "</pre>";
$specarray = new specialArray($data);
print_r($specarray->fieldspec);
$newdata = $specarray->fill_spec_array();

?>
<pre>
	fill_spec_array()
	/**
	* Will execute a 'makefunction' on any column in the array set where the function is specified.
	* This the makefunction can either be a function specified in the fieldspec['makefunction'] or it can
	* be a function called make_<column name>.  The original value is pased into the function in either case.
	* If neither exist, just use the value.
	*/	
</pre>
<?php
echo "<pre>";
print_r($newdata);
echo "</pre>";


?>